package booksys.bod;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

public interface BodDao {
    @Select("select * from bookdefer where st_id=#{userId}")
    List<Bodcard> findNewBodcardList(String userId);

    @Select("select count(*) from bbook where bb_id = #{bb_id}")
    boolean findbook(String bb_id);

    @Select("select lpad(ifnull(max(convert(substring(bd_id,7,3),signed)),0)+1,3,'0')  from bookdefer where bd_id like concat(#{s},'%')")
    String findBodcardNewNum(String s);

    @Insert("insert bookdefer(bd_id,st_id,ma_id,bb_id,bob_id,bd_time,bd_defer,bd_up,bd_agree,bd_extime) values(#{bd_id},#{st_id},#{ma_id},#{bb_id},#{bob_id},#{bd_time},#{bd_defer},#{bd_up},#{bd_agree},#{bd_extime})")
    void insertBobcard(BodcardDto dto);

    @Select("select bob_id from bookborrow where bb_id=#{bb_id} and st_id=#{st_id} and bb_retime is null")
    String finBobid(BodcardDto dto);

    @Select("select ma_id from bookborrow where bob_id=#{Bob_id}")
    String findManagerByBobid(String Bob_id);

    @Select("select count(*) from bbook where bb_id=#{bb_id} and bb_state='1'")
    boolean beborrow(String bb_id);

    @Select("select st_id from bookborrow where bb_id=#{bb_id} and bob_id=#{bob_id}")
    String getst_id(BodcardDto dto);

    @Select("select count(*) from bookdefer where bb_id=#{bb_id} and bob_id=#{bob_id} and bd_up=1 and bd_agree=0")
    int getbd_up(BodcardDto dto);

    @Select("select bb_extime from bookborrow where bob_id=#{bob_id}")
    String getbob_extime(BodcardDto dto);

    @Select("select count(*) from bookdefer where bb_id=#{bb_id} and bob_id=#{bob_id} and bd_up=1 and bd_agree=1")
    int getbd_upxx(BodcardDto dto);
}
